install.packages("igraph")
library("igraph")
library(readr)
library(haven)
library(ggplot2)
Ashmat <- as.matrix(Ash_Cloud)
sna <- graph_from_edgelist(Ashmat, directed = TRUE)
degdistr_sna <- degree_distribution(sna, mode="in")
deg_distr_sna2 <- as.data.frame(degdistr_sna)
qplot(degdistr_sna, data =deg_distr_sna2, geom="histogram", binwidth=.001,
      ylim =range(0, 8))

degree_sna <- degree(sna, mode ="in")
hist(degree_sna, breaks = seq(0,(max(degree_sna)+1), by=0.5), 
     xlim = range(0,20), ylim = range(0, 5), main = "in-degree distribution", 
     xlab = "in-degree", ylab = "frequency")

Ebolamat <- as.matrix(Ebola_SNA)
sna.eb <- graph_from_edgelist(Ebolamat, directed = TRUE)
degdistr_sna.eb <- degree_distribution(sna.eb, mode="in")
deg_distr_sna.eb2 <- as.data.frame(degdistr_sna.eb)
qplot(degdistr_sna.eb, data =deg_distr_sna.eb2, geom="histogram", binwidth=.001,
      ylim =range(0, 20))

degree_sna.eb <- degree(sna.eb, mode ="in")
hist(degree_sna.eb, breaks = seq(0,(max(degree_sna.eb)+1), by=0.5), xlim = range(0,40), ylim = range(0,5),
     main = "in-degree distribution", xlab = "in-degree", ylab = "frequency")


idmat <- as.matrix(Idai)
sna.id <- graph_from_edgelist(idmat, directed = TRUE)
degdistr_sna.id <- degree_distribution(sna.id, mode="in")
deg_distr_sna.id2 <- as.data.frame(degdistr_sna.id)
qplot(degdistr_sna.id, data =deg_distr_sna.id2, geom="histogram", binwidth=.001)

degree_sna.id <- degree(sna.id, mode ="in")
hist(degree_sna.id, breaks = seq(0,(max(degree_sna.id)+1), by=0.5), xlim = range(0,25), ylim = range(0,4), 
     main = "in-degree distribution", xlab = "in-degree", ylab = "frequency")
